package model

import (
	"main/database"
)

type User struct {
	Id	     int `json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type UserInfo struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

//新增用户
func CreateUser(user *User)(err error){
	err = database.DB.Create(&user).Error
	return
}

//查询用户
func FindUser(userInfo *UserInfo)(user *User,err error){
	user = new(User)
	if err = database.DB.Debug().Where("username=? AND password=?",userInfo.Username,userInfo.Password).First(user).Error;err!=nil{
		return nil,err
	}
	return
}
